﻿@model MvcAgenda.Models.UsersListViewModel

@{
    ViewBag.Title = "Index";
}

<h2>Index</h2>

<p>
    @Html.ActionLink("Create New", "Create")
</p>
<table>
    <tr>
        <th>
            @Html.DisplayNameFor(model => model.Users.First().username)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.Users.First().password)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.Users.First().email)
        </th>
        <th></th>
    </tr>

@foreach (var item in Model.Users)
{
    <tr>
        <td>
            @Html.DisplayFor(modelItem => item.username)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.password)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.email)
        </td>
        <td>
        @using (Html.BeginForm("Create", "Events", FormMethod.Get)) { 
        @Html.HiddenFor(modelItem => item.id)
        @Html.Hidden("returnUrl", Request.Url.PathAndQuery)
        <input type="submit" value="+ Add Event" />
        }
        </td>
        <td>
        @using (Html.BeginForm("ResetPassword", "Users")){ 
       @Html.Hidden("id", item.id)
        @Html.Hidden("returnUrl", Request.Url.PathAndQuery)
        <input type="submit" value="+ Reset Password" />
        }
        </td>
        <td>
            @Html.ActionLink("Edit", "Edit", new { id=item.id }) |
            @Html.ActionLink("Details", "Details", new { id=item.id }) |
            @Html.ActionLink("Delete", "Delete", new { id=item.id })
        </td>
    </tr>
}

</table>
<div class="pager"> 
@Html.PageLinks(Model.PagingInfo, x => Url.Action("Index", new { page = x }))
</div>
